/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package alcatelparser.modules;

import java.io.File;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.IOException;
import java.util.Properties;

/**
 *
 * @author geniuz
 */
public class ApplicationSettings
{

    private ApplicationSettings()
    {
        try
        {
            _props = new Properties();
            File file = new File(getSetttingsPath(true));
            if(file.exists())
                _props.load(new FileInputStream(file));
            else
                _props.load(new FileInputStream(getSetttingsPath(false)));
        }
        catch(IOException ioexception)
        {
            //throw new ApplicationInitalyzeError(I.I(708));
        }
    }

    public static final ApplicationSettings getInstance()
    {
        if(_settins == null)
            try
            {
                _settins = new ApplicationSettings();
            }
            catch(Exception applicationinitalyzeerror)
            {
                System.out.println(I.I(693));
            }
        return _settins;
    }

    public static final void initialyze()
    {
        _settins = new ApplicationSettings();
    }

    public final String getProperty(String s)
    {
        return _props.getProperty(s);
    }

    public final void setProperty(String s, String s1)
    {
        _props.setProperty(s, s1);
    }

    public final void storeProperty()
    {
        try
        {
            _props.store(new FileOutputStream(getSetttingsPath(true)), I.I(637));
        }
        catch(IOException ioexception)
        {
            //LOG.error(ioexception);
        }
    }

    private String getSetttingsPath(boolean flag)
    {
        String s = flag ? I.I(616) : "";
        return (new StringBuilder()).append(Env.getEnv().getRunDir()).append(File.separator).append(s).append(I.I(622)).toString();
    }

    private static ApplicationSettings _settins;
    private static final String FILE_USER_PREFIX = "user_";
    private Properties _props;
    public static final String DEFAULT_SS_NUMBER = "2";
    private static final String APPLICATION_SETTINGS_FILE_NAME = "settings.props";
    //private static final Logger LOG = Logger.getLogger(com/alcatel/properties/ApplicationSettings);

}
